﻿@*
    生产任务单管理页面
     create date:
     last edit:2019.11.22 ben   加急订单设置红色
    2019.12.16 ben //修改调整计划、自动排程等操作结果不返回详情、仅反馈成功。
    2020.1.11   调整分页大小为50
    2020.2.3   调整分页大小30
*@
@{
    Layout = null;
}

<!DOCTYPE html>

<html>
<head>
    <meta name="viewport" content="width=device-width" />
    <title>生产任务单</title>
    <link href="~/Scripts/jquery-easyui/themes/bootstrap/easyui.css" rel="stylesheet" />
    <script src="~/Scripts/jquery-easyui/jquery.min.js"></script>
    <script src="~/Scripts/jquery-easyui/jquery.easyui.min.js"></script>
    <script src="~/Scripts/jquery-easyui/locale/easyui-lang-zh_CN.js"></script>
    <link href="~/Content/themes/icon.css" rel="stylesheet" />
    <script src="~/Content/js/common.js"></script>
    <link href="~/Content/themes/table.css" rel="stylesheet" />
    <script src="~/Scripts/jquery-easyui/Extension/jquery-easyui-datagridview/datagrid-detailview-ben.js"></script>
    <script src="~/Content/js/module_cols_defined.js"></script>
    <script src="~/Scripts/jsrender.js"></script>
    <script type="text/javascript">

        var pk = "FBillNo";//不隐藏的主键
        var module_dialog = "#module_dialog";
        var flag = "ProjectGrid";//页面标签       
        var currentUserId = window.parent.RealName || "test_admin";//当前用户
        var billFStatus = "unFinished";//选择单据状态全局变量，默认显示未完成单据
        var mainbillno = "";//主单的单号；
        var Dept = decodeURI(getQueryVariable("Dept") || "all");// encodeURI(deName)
        var year = getQueryVariable("year") || 2019;
        var view = getQueryVariable("view") || "ProjectGrid";
        var FBillNo = getQueryVariable("FBillNo") || "";//传入的查询单据号

        var selectedRows = new Array();//全局选中单据数组        // var fbillnos = {};
        var lock = false;//全局操作锁

        //表格列定义
        var frozenColumns = [[

        ]];
        var myColums = [[{ field: 'hasChild', title: '', width: 25, expander: true },
                             { field: 'ck', checkbox: true },
                       {
                           title: '编号', field: 'FBillNo', sortable: true, styler: function (value, row, index) {
                               if (row.overdue) {//逾期
                                   return 'background-color:#FF8000;color:#fff;';
                               } else if (row.notStart) {//未开工
                                   return 'background-color:#FFFF66;color:blue;font-weight:bold;';
                               }
                           }
                       },
                            { width: 90, title: '制单日期', field: 'FHEADSELFJ0178', hidden: false, sortable: true, formatter: function (value, row, index) { return value.substring(0, value.indexOf(' ')) } },
                            {
                                title: '单据类型', field: 'FWORKTYPEID', formatter: function (value, row, index) {
                                    var x;
                                    switch (value) {
                                        case 0:
                                            x = "虚拟";
                                            break;
                                        case 68:
                                            x = "加急订单";
                                            break;
                                        case 55:
                                            x = "普通订单";
                                            break;
                                        case 57:
                                            x = "备件计划";
                                            break;
                                        case 1004:
                                            x = "研发项目";
                                            break;
                                        case 1002:
                                            x = "维修";
                                            break;
                                        default:
                                            x = value;
                                    }
                                    return x;
                                }, styler: function (value, row, index) {
                                    if (value == 68) {//加急订单，底色红色，蓝字
                                        return 'background-color:#f22126;color:blue;font-weight:bold;';
                                    }
                                }
                            },
                            {
                                width: 60, title: '单据状态', hidden: false, field: 'FStatus', formatter: function (value, row, index) {
                                    var x;

                                    switch (value) {
                                        case 0:
                                            x = "计划";
                                            break;
                                        case 1:
                                            x = "未完成";
                                            break;
                                        case 2:
                                            x = "未完成";
                                            break;
                                        case 3:
                                            x = "已完成";
                                            break;
                                        default:
                                            x = value;
                                    }
                                    return x;
                                }
                            },
                             {
                                 width: 60, title: '关闭标志', field: 'fmrpclosed', hidden: true,
                                 formatter: function (value, row, index) {
                                     return value ? '<img src="../../Content/themes/icon/chk_checked.gif" alt="已关闭" title="已关闭" />' : '<img src="../../Content/themes/icon/chk_unchecked.gif" alt="未关闭" title="未关闭" />';
                                 }
                             },
                                {
                                    width: 120, title: '物料名称', field: 'FName', formatter: function (value, row, index) {
                                        return value.length > 8 ? '<span title="' + value + '">' + value + '</span>' : value;
                                    }
                                },
                                {
                                    width: 120, title: '规格型号', field: 'FModel', formatter: function (value, row, index) {
                                        return value.length > 8 ? '<span title="' + value + '">' + value + '</span>' : value;
                                    }
                                },
                                { width: 60, title: '计划数量', field: 'FQty' },
                                { width: 60, title: '实际数量', field: 'FCommitQty' },
                                  { width: 60, title: '入库数量', field: 'fauxstockqty', hidden: false },
                                   { width: 60, title: '在制数量', field: 'FHEADSELFJ0182', hidden: false },
                                  { width: 60, title: '库存数量', field: 'FStockQty', hidden: false },
                                  { width: 90, title: '计划开工日期', field: 'FPlanCommitDate', sortable: true, formatter: function (value, row, index) { return value.substring(0, value.indexOf(' ')) } },
                                  { width: 90, title: '计划完工日期', field: 'FPlanFinishDate', sortable: true, formatter: function (value, row, index) { return value.substring(0, value.indexOf(' ')) } },
                                    { width: 90, title: '单据下达日期', field: 'FCheckDate', sortable: true, formatter: function (value, row, index) { return value.substring(0, value.indexOf(' ')) }, hidden: true },
                                    { width: 90, title: '实际开工日期', field: 'FStartDate', sortable: true, formatter: function (value, row, index) { return value.substring(0, value.indexOf(' ')) } },
                                    { width: 90, title: '实际完工日期', field: 'FFinishDate', sortable: true, formatter: function (value, row, index) { return value.substring(0, value.indexOf(' ')) } },
                                     {
                                         width: 60, title: '是否领料', field: 'ppbomstatus', hidden: false,
                                         formatter: function (value, row, index) {
                                             return value == 1 ? '<img src="../../Content/themes/icon/chk_checked.gif" alt="已领料" title="已领料" />' : '<img src="../../Content/themes/icon/chk_unchecked.gif" alt="未领料" title="未领料" />';
                                         }
                                     },
                                    { width: 60, title: '生产进度', field: 'FHEADSELFJ0183', hidden: false },
                                     { title: '部门', field: 'fheadselfj0181', hidden: false,formatter: function (value, row, index) {
                                         if (value) { return value.substring(0, 4); }
                                     } },
                                    { title: '更新人', field: 'fheadselfj0186', hidden: false },
                                    { width: 60, title: '逾期', field: 'overdue', hidden: true },
                                    { width: 60, title: '首道工序未开工预警', field: 'notStart', hidden: true },


        ]];
        
        var conf = {
            options: {
                url: "/Project/GetPageProjectInfo",
                striped: true, rownumbers: true, pagination: true, pageSize: 30, singleSelect: false,
                fitColumns: false,
                idField: 'FBillNo',
                sortName: 'FPlanFinishDate',
                sortOrder: 'asc',
                pageList: [30,60,90],//[20, 40, 60, 80, 100],
                queryParams: {
                    "view":view,
                    "FStatus": billFStatus,
                    "year": year,
                    "Dept": Dept,
                    "FBillNo": FBillNo,
                },
               // frozenColumns: frozenColumns,
                onLoadSuccess: function () {
                },
                columns: myColums,
                rowStyler:function(index,row){
                  
                },
                onSelect: function (index, row) {
                    onSelectRow(index, row);
                },
                onUnselect: function (index, row) {
                    onUnselectRow(index, row);
                },
                onClickRow: function (rowIndex, rowData) {
                    getSelectedFbillno(rowIndex, rowData);
                },
                onDblClickRow: function (rowIndex, rowData) {
                    $('#w').window('open');
                    loadwork(rowIndex, rowData);
                },
                onBeforeRender: function (target, rows) { 

                },
                onLoadSuccess: function (data) { 
                    //for (i = 0; i < data.rows.length; i++) alert(data.rows[i].FName);
                }
                //toolbar: toolbar.length == 0 ? null : toolbar
            },
            subgrid: {
                options: {
                    fitColumns: false,
                    foreignField: 'FBillNo',
                    url: "/Project/GetProjectEntry",
                    striped: true, rownumbers: false, pagination: true, pageSize: 10, singleSelect: false,
                    idField: 'FBillNo',
                    pageList: [5, 8, 10, 15, 20],
                    frozenColumns: frozenColumns,
                    columns: myColums,
                    rowStyler: function (index, row) { 
                      
                    },
                    showHeader: false,
                    queryParams: { 
                        "FStatus": billFStatus,
                         "subclass": 1
                    },

                    onResize: function () { },
                    onLoadSuccess: function (data) {                       
                        //for (i = 0; i < data.rows.length; i++) alert(data.rows[i].FName);
                    },
                    onSelect: function (index, row) {
                        onSelectRow(index, row);
                    },
                    onUnselect: function (index, row) {
                        onUnselectRow(index, row);
                    },
                    onClickRow: function (rowIndex, rowData) {
                        getSelectedFbillno(rowIndex, rowData);
                    },
                    onDblClickRow: function (rowIndex, rowData) {
                        $('#w').window('open');
                        loadwork(rowIndex, rowData);
                    }
                },
                subgrid: {                 
                    options: {
                        showHeader: false,
                        fitColumns: false,
                        foreignField: 'FBillNo',
                        idField: 'FBillNo',
                        url: "/Project/GetProjectEntry",
                        singleSelect: false,
                        frozenColumns: frozenColumns,
                        columns: myColums,
                        queryParams: {
                            "subclass": 2,
                            "FStatus": billFStatus
                        },
                        rowStyler: function (index, row) {
                           
                        },
                        onResize: function () { },
                        onSelect: function (index, row) {
                            onSelectRow(index, row);
                        },
                        onUnselect: function (index, row) {
                            onUnselectRow(index, row);
                        },
                            onClickRow: function (rowIndex, rowData) {
                                     getSelectedFbillno(rowIndex, rowData);
                                    },
                        onDblClickRow: function (rowIndex, rowData) {
                            $('#w').window('open');
                            loadwork(rowIndex, rowData);
                        }
                    },
                    subgrid:{
                        options: {
                            showHeader: false,
                            fitColumns: false,
                            foreignField: 'FBillNo',
                            idField: 'FBillNo',
                            url: "/Project/GetProjectEntry",
                            singleSelect: false,
                            frozenColumns: frozenColumns,
                            columns: myColums,
                            rowStyler: function (index, row) {
                              
                            },
                            queryParams: {
                                "subclass": 3,
                                "FStatus": billFStatus
                            },
                            onResize: function () { },
                            onSelect: function (index, row) {
                                onSelectRow(index, row);
                            },
                            onUnselect: function (index, row) {
                                onUnselectRow(index, row);
                            },
                            onClickRow: function (rowIndex, rowData) {
                                getSelectedFbillno(rowIndex, rowData);
                            },
                            onDblClickRow: function (rowIndex, rowData) {
                                $('#w').window('open');
                                loadwork(rowIndex, rowData);
                            }
                        }, subgrid: {
                            options: {
                                showHeader: false,
                                fitColumns: false,
                                foreignField: 'FBillNo',
                                idField: 'FBillNo',
                                url: "/Project/GetProjectEntry",
                                singleSelect: false,
                                frozenColumns: frozenColumns,
                                columns: myColums,
                                rowStyler: function (index, row) {
                                  
                                },
                                queryParams: {
                                    "subclass": 4,
                                    "FStatus": billFStatus
                                },
                                onResize: function () { },
                                onSelect: function (index, row) {
                                    onSelectRow(index, row);
                                },
                                onUnselect: function (index, row) {
                                    onUnselectRow(index, row);
                                },
                                onClickRow: function (rowIndex, rowData) {
                                    getSelectedFbillno(rowIndex, rowData);
                                },
                                onDblClickRow: function (rowIndex, rowData) {
                                    $('#w').window('open');
                                    loadwork(rowIndex, rowData);
                                }
                            },
                            subgrid: {
                                options: {
                                    showHeader: false,
                                    fitColumns: false,
                                    foreignField: 'FBillNo',
                                    idField: 'FBillNo',
                                    url: "/Project/GetProjectEntry",
                                    singleSelect: false,
                                    frozenColumns: frozenColumns,
                                    columns: myColums,
                                    rowStyler: function (index, row) {
                                     
                                    },
                                    queryParams: {
                                        "subclass": 5,
                                        "FStatus": billFStatus
                                    },
                                    onResize: function () { },
                                    onSelect: function (index, row) {
                                        onSelectRow(index, row);
                                    },
                                    onUnselect: function (index, row) {
                                        onUnselectRow(index, row);
                                    },
                                    onClickRow: function (rowIndex, rowData) {
                                        getSelectedFbillno(rowIndex, rowData);
                                    },
                                    onDblClickRow: function (rowIndex, rowData) {
                                        $('#w').window('open');
                                        loadwork(rowIndex, rowData);
                                    }
                                }
                            }
                        }
                    }
                }
            }
        };

        //}


        $(function () {
            $.ajax({     //请求当前用户可以操作的按钮
                url: "/Button/GetUserAuthorizeButton?r=" + Math.random(),
                type: "post",
                data: { "KeyCode": "produceOrder", "KeyName": "Produce" },
                dataType: "json",
                method: "post",
                timeout: 5000,
                success: function (data) {
                    if (data.success) {                        
                        if (data.search) {     //判断是否有浏览权限
                            data.toolbar.push('-', { "text": "清除选择", "id": "btUnselectAll", "iconCls": 'icon-chk_unchecked', "handler": "$('#ui_produce_dg').datagrid('clearSelections').datagrid('clearChecked');" })
                            var toolbar = getToolBar(data);      //common.js                         
                            $("#ui_produce_dg").datagrid({
                                toolbar: toolbar.length == 0 ? null : toolbar,
                                onLoadSuccess: function (data) {
                                    // loadColumnDefined($("#ui_produce_dg"), currentUserId, pk, flag);//列自定义                                   

                                }
                                //title: '生产任务单管理',
                                //width:1000 ,
                                //height: 600
                            }).datagrid('subgrid', conf)
                        }
                        else {
                            $.show_alert("提示", "无权限，请联系管理员！");
                        }
                    } else {
                        $.show_alert("错误", data.result);
                    }
                },
                error: function (XMLHttpRequest, textStatus, errorThrown) {
                    if (textStatus == "timeout") {
                        $.show_alert("提示", "请求超时，请刷新当前页重试！");
                    }
                    else {
                        $.show_alert("错误", textStatus + "：" + errorThrown);
                    }
                }
            })


            //回车搜索
            $("#ui_project_search").find('input').on('keyup', function (event) {
                if (event.keyCode == '13') {
                    ui_project_searchdata();
                }
            })

        });

        //动态加载标题和数据，显示项目对应的工序计划；主表内业务处理
        function loadwork(rowIndex, rowData) {   
            $.ajax({
                url: "/Project/GetPageProcessInfo?FBillNo=" + rowData['FBillNo'],// + "&FName=" + rowData['FName'],
                type: "post",
                dataType: "text",
                success: function (result) {
                    map = $.parseJSON(result);
                    if (map.rows) {
                        //json数据中增加新列
                        for (var k in map.rows) {
                            map.rows[k]['FName'] = rowData['FName'];
                        }
                        $('#pworktable').datagrid('loadData', map.rows); //将返回的数据绑定到datagrid
                    } else {
                        $.messager.alert('Info', "没有找到记录！", 'info');
                    }

                }
            });
        }

        //主表绑定双击事件；
        //$(function () {
        //    $('#ui_produce_dg').datagrid({
        //        onDblClickRow: function (rowIndex, rowData) {
        //            $('#w').window('open');
        //            loadwork(rowIndex, rowData);
        //        }
        //    });
        //});

       


       

        function getSelectedFbillno(rowIndex, rowData) {
           // mfbillno = rowData['FBillNo'];
           // mfName = rowData['FName'];
           //mhasChild = rowData.hasChild;
           //  console.log(mfbillno + ",mfName:" + mfName + ",hasChild:" + rowData.hasChild + ",ppbomstatus:" + rowData.ppbomstatus);
            };
      
 

       


        //通用行选择处理函数
        function onSelectRow(index, row) {
            if ($.inArray(row, selectedRows) < 0) {
                // $.extend(selectedRows, row);
                selectedRows.push(row);
            }
            var log='已选择的单据号：'
            $.each(selectedRows, function (n, value) {

                log+=value.FBillNo+';';
            });           
            console.log(log,"总数"+selectedRows.length);
        };
        //通用行反选处理函数
        function onUnselectRow(index, row) {

            var pos = $.inArray(row, selectedRows);
            if (pos >= 0) {
                selectedRows.splice(pos, 1);
            }
            var log = '已选择的单据号：'
            $.each(selectedRows, function (n, value) {

                log += value.FBillNo + ';';
            });
            console.log(log, "总数" + selectedRows.length);
        };

        
        //自动排程,处理所有可处理单据
        function schedule() {
            if (lock) { return;}
            $.messager.confirm('提示', '确定要对所有任务单进行自动排程吗？', function (r) {
                if (r) {
                    $.show_alert("提示", "自动排程任务已提交服务器，无需等待，由于计算时间较长，请勿重复点击，可于5分钟后查看排程结果。");
                    lock = true;
                    $.ajax({
                        url: "/Schedule/doAllSchedule?r=" + Math.random(),
                        data: {
                            //fbillno: mfbillno                           
                        },
                        dataType: "json",
                        type: "POST",
                        success: function (data) {
                            lock = false;
                            if (data.success) {
                               // $.show_alert("提示", data.msg);
                                $.show_alert("提示", "自动排程操作成功！");
                            } else {
                                $.show_alert("提示", data.msg);
                            }
                        }
                    });


                }
            });
        }
              
        //变更任务单类型：加急等，允许跨层级、跨主单多选
        function alterWorkType() {           
            if (selectedRows.length < 1) {
                $.show_alert("提示", "请选择要变更的订单，允许多选！");
                return;
            }       
            var FBillNos = "";
            var fbillCount = 0;
            $.each(selectedRows, function (n, value) {
                if (value.FItemID > 0) { FBillNos += value.FBillNo + ','; fbillCount += 1;}
                    });
            FBillNos = FBillNos.substring(0, FBillNos.length - 1); 
            var data = {
                'count': selectedRows.length,
                'FBillNos': FBillNos,
                'fbillCount': fbillCount
            };
            var html_alterbill = $("#Tmp_alterBill").render(data);

            $("<div/>").dialog({
                id:'alterWorkTypeP',
                title: '变更订单类型',
                width: 500,
                height: 300,
                closed: false,
                cache: false,
                content: html_alterbill,
               // href: 'get_content.php',
                modal: true,
                buttons: [{
                    text: 'Ok',
                    iconCls: 'icon-ok',
                    handler: function () {
                        if (fbillCount == 0) return;
                        if (lock) { return; } else { lock = true; }
                        $.ajax({
                            url: "/Project/alterWorkType?r=" + Math.random(),
                            type: "post",
                            data: {
                                FBillNo: FBillNos,
                                worktypeID: $('#ss_workType').val(),                                
                            },
                            dataType: "json",
                            timeout: 5000,
                            success: function (data) {
                                lock = false;
                                if (data.success) {
                                    $.show_alert("返回结果", data.msg);
                                    $('#alterWorkTypeP').dialog('close', true);
                                    $("#ui_produce_dg").datagrid("reload");//刷新主表
                                    $("#ui_produce_dg").datagrid('clearSelections').datagrid('clearChecked');
                                    selectedRows.length = 0;//清空数组； 
                                } else {
                                    $.show_alert("提示", data.msg);
                                }
                            },
                            error: function (XMLHttpRequest, textStatus, errorThrown) {
                                if (textStatus == "timeout") {
                                    $.show_alert("提示", "请求超时，请刷新当前页重试！");
                                }
                                else {
                                    $.show_alert("错误", textStatus + "：" + errorThrown);
                                }
                            }
                        });
                        
                    }
                }, {
                    text: 'Cancel',
                    handler: function () {
                         $('#alterWorkTypeP').dialog('close', true);
                        //$('#alterWorkTypeP').dialog('close', true);
                    }
                }]
            });
        }
         

        //调整计划
        function adjustplan() {
            var mfbillno = "";
            var mfName = "";
            var mhasChild = false;
            if (selectedRows.length != 1) {
                $.show_alert("提示", "请选择要调整的订单，仅允许单选！");
                return;
            } else {
                mfbillno = selectedRows[0].FBillNo;
                mfName = selectedRows[0].FName;
                mhasChild=selectedRows[0].hasChild;

                var data = {
                    'FBillNo': selectedRows[0].FBillNo,
                    'FName': selectedRows[0].FName,
                    'mhasChild': selectedRows[0].hasChild,
                };
                var html_adjustBillPlan = $("#Tmp_adjustBillPlan").render(data);

            $("<div/>").dialog({
                id: "ui_adjust_plan_dialog",
                //href: "/Project/adjustprojectplan?r=" + Math.random(),
                title: "调整任务单计划日期：",
                width: 500,
                height: 300,
                closed: false,
                cache: false,
                content: html_adjustBillPlan,
                modal: true,
                buttons: [{
                    id: "adjust_confirm_btn",
                    text: '确 定',
                    handler: function () {                       
                        if (!$("#adjustBillPlanForm").form('validate')) {//表单校验
                            $.show_alert("提示", "调整天数应为整数！");
                            return;
                        } 
                        if (lock) { return; } else { lock = true; }
                        $("#adjust_confirm_btn").linkbutton('disable');
                        var days = $("#days").val();
                        var adjustmode = $("#adjustmode").val();
                        if (adjustmode == 'ahead') {
                            days = -days;
                        } 
                        $.ajax({
                            url: "/Project/adjustprojectplanbll?r=" + Math.random(),
                            data: { 
                                fbillno: mfbillno,
                                hasChild:mhasChild,
                                days: days,
                                adjustmode: adjustmode
                            },
                            dataType: "json",
                            type: "POST",
                            success: function (data) {
                                lock = false;
                                if (data.success) {                                   
                                    $("#ui_adjust_plan_dialog").dialog('destroy');
                                    // $.show_alert("提示", data.msg);
                                    $.show_alert("提示", "调整计划操作成功");
                                    $("#ui_produce_dg").datagrid("reload");
                                    $("#ui_produce_dg").datagrid('clearSelections').datagrid('clearChecked');
                                    selectedRows.length = 0;//清空数组；
                                } else {
                                    $.show_alert("提示", data.msg);
                                }
                            }
                        });
                    }
                }, {
                    text: '取 消',
                    handler: function () {
                        $("#ui_adjust_plan_dialog").dialog('destroy');
                    }
                }],
                onLoad: function () {
                    $("#days").focus();
                },
                onClose: function () {
                    $("#ui_adjust_plan_dialog").dialog('destroy');  //销毁dialog对象
                }
            });
            }
        }

     


        //搜索任务单
        function ui_project_searchdata() {
            inputDept = $('#inputDept').val();//获取部门选项值
            //动态修改搜索任务单的完成状态
            billFStatus = $('#FStatus').val();
            $('#ui_produce_dg').datagrid('options').subgrid.options.queryParams.FStatus = billFStatus;
            $('#ui_produce_dg').datagrid('options').subgrid.subgrid.options.queryParams.FStatus = billFStatus;
            $('#ui_produce_dg').datagrid('options').subgrid.subgrid.subgrid.options.queryParams.FStatus = billFStatus;
            $("#ui_produce_dg").datagrid('load', {
                FBillNo: $('#FBillNo').val(),
                view: 'ProjectGrid',
                FName: $('#FName').val(),
                Dept: inputDept,//部门
                FWORKTYPEID:$('#FWORKTYPEID').val(),//订单类型
                FStatus: billFStatus,
                FModel: $('#FModel').val(),
                FPlanCommitDate: $('#FPlanCommitDate').datetimebox('getValue')
                //fbominterid: $('#fbominterid').val()
            });
            $("#ui_produce_dg").datagrid('clearSelections').datagrid('clearChecked');
            selectedRows.length = 0;//清空数组；
        }
        //清除搜索条件
        function ui_project_cleardata() {
            $('#ui_project_search input').val('');
           // $('#ui_project_search select').val('select');
            $('#txtAddBeginDate').datetimebox('setValue', '');
            $('#txtAddEndDate').datetimebox('setValue', '');
            $("#ui_produce_dg").datagrid('load', {});           
            $("#ui_produce_dg").datagrid('clearSelections').datagrid('clearChecked');
            selectedRows.length = 0;//清空数组；
        }
    </script>
    
    <script type="text/x-jsrender" id="Tmp_adjustBillPlan">
        <div style="padding: 15px; overflow: hidden">
            <form id="adjustBillPlanForm">
                <table class="tableForm" style="width: 99%; height: 100%; background: #F5F5F5;table-layout:fixed;">
                    <tr> <th style="width:150px">选择调整的单号为：</th> <td>{{:FBillNo}} </td></tr>
                    <tr><th> 物料名称 </th> <td>{{:FName}} </td></tr>
                    <tr>
                        <th>调整方式：</th>
                        <td>
                            <select name="adjustmode" id="adjustmode">
                                <option value="ahead">提前</option>
                                <option value="putoff" selected="selected">推迟</option>
                            </select>
                        </td>
                    <tr><th> 调整天数： </th> <td><input type="text" id="days" class="easyui-textbox" data-options="validType:'integer', required:true" /> </td></tr>
                    <tr><td colspan="2" style="WORD-WRAP: break-word;">注意：调整计划将自动关联所有下级任务单及工序计划单。高耗时操作，请耐心等待！</td></tr>
                </table>
            </form>
        </div>
    </script>

  


    <script type="text/x-jsrender" id="Tmp_alterBill">
        <div style="padding: 15px; overflow: hidden">
            <table class="tableForm" style="width: 99%; height: 100%; background: #F5F5F5;table-layout:fixed;">
                <tr> <th style="width:150px">共选择订单：</th> <td>{{:count}}条 </td></tr>
                <tr><th> 排除虚拟订单后 </th> <td>共{{:fbillCount}}条 </td></tr>
                <tr><th> 提交变更的单号： </th> <td style="WORD-WRAP: break-word;">{{:FBillNos}} </td></tr>
                <tr>
                    <th>选择要变更的类型：</th>
                    <td>
                        <select name="ss_workType" id="ss_workType">
                            <option value="68" selected="selected">加急订单</option>
                            <option value="55">普通订单</option>
                            <option value="57">备件计划</option>
                            <option value="1004">研发项目</option>
                            <option value="1002">维修</option>
                        </select>
                    </td>
                </tr>
            </table>
        </div>
    </script>
 
 

</head>
<body>
    <div id="ui_project_layout" class="easyui-layout" data-options="fit:true,border:false">
        <div data-options="region:'north',split:true,border:true,collapsed:true" title="条件搜索" style="height:104px;">
            <div id="ui_project_search">
                <table class="tableForm" style="width: 99%; height: 100%; background: #F5F5F5;">
                    <tr>
                        <th>
                            订单号：
                        </th>
                        <td>
                            <input name="FBillNo" id="FBillNo" class="easyui-validatebox textbox" style="width:150px;height:22px;" />
                        </td>

                        <th>
                            物料名称：
                        </th>
                        <td>
                            <input name="FName" id="FName" class="easyui-validatebox textbox" style="width:150px;height:22px;" />
                        </td>
                        <th>
                            部门：
                        </th>
                        <td>
                            <select  id="inputDept">
                                <option value="all" selected="selected">所有</option>
                                <option value="电缆卷筒事业部">电缆卷筒事业部</option>
                                <option value="冶金工程事业部">冶金工程事业部</option>
                                <option value="钢水控流事业部">钢水控流事业部</option>
                                <option value="能源环保事业部">能源环保事业部</option>
                                <option value="制造事业部">制造事业部</option>
                                <option value="other">其他</option>@*null、0 not like ‘事业部’*@
                            </select> 
                        </td>

                        <th>
                            订单状态：
                        </th>
                        <td>
                            <select name="FStatus" id="FStatus">
                                <option value="all">全部主单</option>
                                <option value="finished">已完成</option>
                                <option value="unFinished" selected="selected">未完成</option>
                                <option value="overdue">逾期</option>
                                <option value="notStart">首道工序预警</option>
                                <option value="includeSub">不区分主子单</option>
                            </select>
                        </td>
                    </tr>
                    <tr>
                        <th>
                            计划开工时间：
                        </th>
                        <td>
                            <input name="FPlanCommitDate" id="FPlanCommitDate" class="easyui-datetimebox"
                                   editable="false" style="width:150px;height:22px;" />
                        </td>
                        <th>
                            规格型号：
                        </th>
                        <td>
                            <input name="FModel" id="FModel" class="easyui-validatebox textbox" style="width:150px;height:22px;" />
                            @*<input id="fbominterid" name="fbominterid" class="easyui-validatebox textbox" style="width:150px;height:22px;" />*@
                        </td>
                        <th>
                            单据类型：
                        </th>
                        <td>
                            <select name="FWORKTYPEID" id="FWORKTYPEID">
                                <option value="all" selected="selected">全部</option>
                                <option value="0">虚拟</option>
                                <option value="68" >加急订单</option>
                                <option value="55">普通订单</option>
                                <option value="57">备件计划</option>
                                <option value="1004">研发项目</option>
                                <option value="1002">维修</option>
                            </select> 
                        </td>

                        <td colspan="2">
                            <a href="javascript:void(0);" class="easyui-linkbutton" iconcls="icon-search" plain="true"
                               onclick="ui_project_searchdata();">搜索</a>
                            <a href="javascript:void(0);" class="easyui-linkbutton" iconcls="icon-clear" plain="true"
                               onclick="ui_project_cleardata();">清空条件</a>
                            @*<a href="javascript:void(0);" onclick="CreateFormPage('打印测试', $('#ui_produce_dg'));">打印</a>*@
                        </td>
                    </tr>
                </table>
            </div>
        </div>
        <div id="print_produce_dg" data-options="region:'center',border:false">
            <table id="ui_produce_dg" data-options="fit:true,border:false"></table>
        </div>
        <div id="printdiv" hidden="hidden">blank </div>
    </div>
    <div id="w" class="easyui-window" title="工序计划表" closed="true" data-options="iconCls:'icon-save',minimizable:false,tools:'#tt'" style="width:990px;height:400px;padding:10px;">
        <table id="pworktable" class="easyui-datagrid" data-options="rownumbers:false, singleSelect:true, autoRowHeight:false, pagination:false, resizeHandle:'right'">
            <thead>
                <tr> 
                    <th data-options="field:'fwbinterid',width:90,hidden: 'true'">工单id编号</th>
                    <th data-options="field:'ficmono',width:90,hidden: 'true'">编号</th>
                    <th data-options="field:'FName',width:80,hidden:true">产品名称</th>
                    <th data-options="field:'fentryid',width:30">序号</th>
                    <th data-options="field:'fopernote',width:70,align:'right'">工序名称</th>
                    <th data-options="field:'FQTYPLAN',width:50,hidden: true">数量</th>
                    <th data-options="field:'ftotalworktime',width:50">总工时</th>
                    <th data-options="field:'FEntrySelfz0374',width:80,align:'center',formatter: function (value, row, index) { return value.substring(0, value.indexOf(' ')) }">预排开工日期</th>
                    <th data-options="field:'FEntrySelfz0375',width:80,align:'center',formatter: function (value, row, index) { return value.substring(0, value.indexOf(' ')) }">预排完工日期</th>
                    <th data-options="field:'FPLANSTARTDATE',width:80,align:'center',formatter: function (value, row, index) { return value.substring(0, value.indexOf(' ')) }">计划开工日期</th>
                    <th data-options="field:'FPLANENDDATE',width:80,align:'center',formatter: function (value, row, index) { return value.substring(0, value.indexOf(' ')) }">计划完工日期</th>
                    <th data-options="field:'FStartWorkDate',width:80,align:'center', formatter: function (value, row, index) { return value.substring(0, value.indexOf(' ')) }">实际开工日期</th>
                    <th data-options="field:'FEndWorkDate',width:80,align:'center',formatter: function (value, row, index) { return value.substring(0, value.indexOf(' ')) }">实际完工日期</th>
                    <th data-options="field:'fcheckdate',width:70,align:'center',formatter: function (value, row, index) { return value.substring(0, value.indexOf(' ')) }">审核日期</th> 
                    <th data-options="field:'fstatus',width:45,align:'center',formatter:function (value, row, index) { if(value<1){return '未开始'};if(value>2){return '已完成'};return value }">状态</th>
                    <th data-options="field:'FWorkCenterID',width:80,formatter:function (value, row, index) { if(value==15293){return '制造部'};if(value==16015){return '委外'};return value }">工作中心名称</th>
                    <th data-options="field:'ffinishtime',width:80,align:'center'">运行时间</th>
                </tr>
            </thead>
        </table>
    </div>
    <div id="module_column_defined_dialog" buttons="#module_column_defined_dialog_button"></div>
    <div style="text-align:center" id="module_column_defined_dialog_button">
        <a href="javascript:void(0)" id="buttone-column-defined-save-select-all" class="easyui-linkbutton" iconcls="icon-edit-rf" onclick="selectAllColumn($('#ui_produce_dg'))">全选</a>
        <a href="javascript:void(0)" id="buttone-column-defined-save" class="easyui-linkbutton" iconcls="icon-ok-rf">确定</a>
        <a href="javascript:void(0)" id="button-column-defined-cancel" class="easyui-linkbutton" iconcls="icon-reload-rf" onclick="resetColumn($('#ui_produce_dg'), currentUserId, pk, flag)">重置</a>
    </div>
</body>
</html>
